<?php

require_once LS_PATH.'/Lspdo.php';

class Model {
	protected $pdo;
	
	function __construct(){
		$this->pdo = new Lspdo();
	}
	
	protected function buildOrderBy($orderBy=''){
		$orderBySql = '';
		if (!empty($orderBy)){
			if (is_array($orderBy)){
				$orderBySql .= " order by ";
				foreach ($orderby as $k => $v){
					$orderBySql .= $k." ".$v.", ";
				}
				$orderBySql = substr($orderBySql, 0, strlen($orderBySql)-2); 
			} else {
				$orderBySql = ' order by '.$orderBy;
			}
		}
		return $orderBySql;
	}
	
	protected function buildWhereSql($where=''){
		$whereSql = '';
		if (is_array($where)&&!empty($where)){
			$whereSql .= " where ";
			foreach ($where as $k => $v){
				$whereSql .= $k." = '".$v."' and ";
			}
			$whereSql = substr($whereSql, 0, strlen($whereSql)-5);
		} else {
			$whereSql = ' where '.$where;
		}
		return $whereSql;
	}
	
}